// let name = 'foo';
// const requireComponent = require('./common/' + name + '.js');
// console.log(requireComponent)

function importAll (r) {
    const cache = {};
    r.keys().forEach(key => cache[key] = r(key));
    return cache
}

let result = importAll(require.context('./common/', true, /\w+\.js$/))
console.log(result)